From: Rui Matos Date: Wed, 2 May 2012 14:23:28 +0000 (+0200) Subject: test-recorder: Create the recorder only after the stage is realized X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6616 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=d579cd16051fd965c55f85b7d0d4050f7db9731f;p=gnome-shell.git test-recorder: Create the recorder only after the stage is realized The recorder needs the stage's XID so it can only be created after the stage is realized. https://bugzilla.gnome.org/show_bug.cgi?id=675301 --- diff --git a/src/test-recorder.c b/src/test-recorder.c index c223bf114..1a8109f4c 100644 --- a/src/test-recorder.c +++ b/src/test-recorder.c @@ -7,12 +7,19 @@ /* Very simple test of the ShellRecorder class; shows some text strings * moving around and records it. */ -static ShellRecorder *recorder; +static ShellRecorder *recorder = NULL; static gboolean stop_recording_timeout (gpointer data) { - shell_recorder_close (recorder); + if (recorder) + { + shell_recorder_close (recorder); + g_object_unref (recorder); + } + + clutter_main_quit (); + return FALSE; } @@ -22,6 +29,15 @@ on_animation_completed (ClutterAnimation *animation) g_timeout_add (1000, stop_recording_timeout, NULL); } +static void +on_stage_realized (ClutterActor *stage, + gpointer data) +{ + recorder = shell_recorder_new (CLUTTER_STAGE (stage)); + shell_recorder_set_filename (recorder, "test-recorder.ogg"); + shell_recorder_record (recorder); +} + int main (int argc, char **argv) { ClutterActor *stage; @@ -86,13 +102,14 @@ int main (int argc, char **argv) "y", 240.0, NULL); - recorder = shell_recorder_new (CLUTTER_STAGE (stage)); - shell_recorder_set_filename (recorder, "test-recorder.ogg"); + g_signal_connect_after (stage, "realize", + G_CALLBACK (on_stage_realized), NULL); clutter_actor_show (stage); - shell_recorder_record (recorder); clutter_main (); + g_object_unref (stage); + return 0; }